<?php
$chave = "rtg4df65g4t";
$security_key = md5(date("YmdHm").$chave);

// requisita backup
$url = "http://localhost/clientController/backuper/";
for($i = 0; $i < 3; $i++){
    $txt = file_get_contents($url."?s=$security_key");
    if($txt != ''){ break; }
}
//baixa backup
$cmd = "cd backups; wget ".$url."tmp/$txt.tar.gz; cd ..; echo 1";
$return = shell_exec($cmd);

if($return == 1){
    // apaga bakup do servidor
    echo file_get_contents($url."?s=$security_key&a=$txt");
}

echo "Backup finalizado.";